//
//  ThirdViewController.m
//  xingzuo
//
//  Created by liuchengming on 17/11/7.
//  Copyright © 2017年 zhouxiong. All rights reserved.
//

#import "ThirdViewController.h"
#import "LuckViewController.h"

@interface ThirdViewController ()

@end

@implementation ThirdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (IBAction)PushView:(id)sender
{
    self.parentViewController.tabBarController.tabBar.hidden = YES;
    //`NSLog(@"%@",[self getText][arc4random_uniform(23)]);
    
    LuckViewController * lkview = [LuckViewController new];
    UIView * view = [UIView new];
    view.backgroundColor = [UIColor
                            colorWithPatternImage:
                            [UIImage imageNamed:
                             [NSString stringWithFormat:@"%u",arc4random_uniform(12)+1]]];
    view.frame = CGRectMake(0, 0, self.view.bounds.size.width,self.view.bounds.size.height );
    
    
    UITextView * textView = [UITextView new];
    textView.frame = CGRectMake(16, 230, self.view.bounds.size.width-32, 200);
    textView.text = [self getText][arc4random_uniform(21)];
    textView.font = [UIFont boldSystemFontOfSize:20];
    textView.editable = NO;
    textView.selectable = NO;
    textView.backgroundColor = [UIColor colorWithRed:220/255.0 green:arc4random_uniform(240)/255.0 blue:arc4random_uniform(100)/255.0 alpha:1];
    
    [lkview.view addSubview:view];
    [lkview.view addSubview:textView];
    [self.navigationController pushViewController:lkview animated:YES];
    
    
    //[self.navigationController pushViewController:lkview animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSArray *)getText
{
    NSString * str = [NSString
                      stringWithContentsOfFile:
                      [[NSBundle mainBundle] pathForResource:
                       [NSString stringWithFormat:@"运势"] ofType:@".txt"]
                      encoding:NSUTF8StringEncoding error:nil];
    NSArray * arr = [str componentsSeparatedByString:@"\n"];
    //NSLog(@"%@",arr.lastObject);
    return arr;
}


- (void)viewDidAppear:(BOOL)animated
{
    self.parentViewController.tabBarController.tabBar.hidden = NO;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
